<template>
  <view class="su-fixed-footer" v-if="!popupOpen && hideOnPopupOpen" :style="{height,padding}" :class="{safeAreaInsetBottom,transparent}">
    <slot></slot>
    <view class="su-fixed-footer__start" v-if="$slots.start">
      <slot name="start"></slot>
    </view>
    <view class="su-fixed-footer__end" v-if="$slots.end">
      <slot name="end"></slot>
    </view>
  </view>
</template>

<script>
  import {mapState} from 'vuex'
  export default {
    name: "su-fixed-footer",
    props: {
      // 是否开启底部安全区适配
      safeAreaInsetBottom: {
        type: Boolean,
        default: true
      },
      hideOnPopupOpen: {
        type: Boolean,
        default: true
      },
      transparent: {
        type: Boolean,
        default: false
      },
      height:{
        type:String,
        default:'50px'
      },
      padding:{
        type:String,
        default:'0'
      },
    },
    computed:{
      ...mapState(['popupOpen'])
    },
    data() {
      return {

      };
    },
    methods:{
      
    }
  }
</script>

<style lang="scss">
  .su-fixed-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 0;
    z-index: 10;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba($color: #fff, $alpha: 1);
    backdrop-filter: blur(20px);
    height: 100upx;
    box-shadow: 0 -3px 5px rgba($color: #000000, $alpha: 0.1);
    font-size: 28upx;
    /deep/.u-button-x{
      display: inline-flex;
      border: none;
      height: 100%;
      border-radius: 0;
    }
    &.transparent{
      background-color: rgba(255,255,255,0);
      box-shadow: none;
    }
    &__start{
      justify-self: flex-start;
      flex: 1;
      text-align: left;
      padding-left: 30upx;
    }
    &__end{
      justify-self: flex-end;
      padding-right: 10upx;
    }

    &.safeAreaInsetBottom {
      padding-bottom: constant(safe-area-inset-bottom) !important;
      padding-bottom: env(safe-area-inset-bottom) !important;
    }

    &~.su-body {
      padding-bottom: 220upx !important;
    }
  }
</style>
